﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FilesToUploadList.aspx.cs" Inherits="iframe_FilesToUploadList" %>
<%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <SharePoint:CssLink runat="server"></SharePoint:CssLink>
</head>
<body style="width:95%">
    <form id="form1" runat="server" style="width:100%">
    
    
    <asp:HiddenField runat="server" ID="hfUploadFilesIds" />
    
    <div style="width:100%;">
            
            <table cellspacing="5" id="tableFileUploadsHolder" width="100%">
            
                <asp:Repeater runat="server" ID="repFiles">
                    <ItemTemplate>
                    
                        <tr>
                            <td>
                                <asp:FileUpload ID="fileUpload" runat="server" CssClass="ms-fileinput" Width="100%" />
                            </td>
                        </tr>
                    
                    </ItemTemplate>
                </asp:Repeater>
            
                
                
            </table>
            
            <asp:Button runat="server" style="display:none" ID="btnPostFiles" />
    
    </div>
    
        <asp:HiddenField runat="server" ID="hfIsConfidential" />
        <asp:HiddenField runat="server" ID="hfTargetFolder" />
        <asp:HiddenField runat="server" ID="hfFilesDeletionDate" />
        
        <asp:HiddenField runat="server" ID="hfUploadResultCode" />
        <asp:HiddenField runat="server" ID="hfUploadResultInfo" />
        
        <asp:HiddenField runat="server" ID="hfErrors" />
        
        <asp:HiddenField runat="server" ID="hfUploadedFilesIdents" />
    
    </form>
    
    <script type="text/javascript">
    
        var tableFileUploadsHolder = document.getElementById("tableFileUploadsHolder");
        
        var allFileInputs = tableFileUploadsHolder.getElementsByTagName("tr");
        
        var currentVisibleInputIndex = 9;
        
        function SetVisibleFileControls()
        {
            for (var i=0; i < currentVisibleInputIndex; i ++)
            {
                allFileInputs[i].style.display = "inline";
            }
        
            for (var i = currentVisibleInputIndex; i < allFileInputs.length; i ++)
            {
                allFileInputs[i].style.display = "none";
            }
        }               
        
        var fileUploadsListManager = new Object();
        
        
        fileUploadsListManager.addFileToUploadCtrl = function()
        {
            currentVisibleInputIndex++;
            SetVisibleFileControls();
        }
        
        var btnPostFiles = document.getElementById("<%= btnPostFiles.ClientID %>");
        
        fileUploadsListManager.postForm = function()
        {
            btnPostFiles.click();
        }
        
        fileUploadsListManager.setConfidentiality = function(isConfidential)
        {
            var hfIsConfidential = document.getElementById("<%= hfIsConfidential.ClientID %>");
            hfIsConfidential.value = isConfidential.toString();         
        }
        
        fileUploadsListManager.setTargetFolder = function(folderPath)
        {
            var hfFolderPath = document.getElementById("<%= hfTargetFolder.ClientID  %>");
            hfFolderPath.value = folderPath;
        }
        
        fileUploadsListManager.getLastErrors = function()
        {
            var hfErrors = document.getElementById("<%= hfErrors.ClientID %>");
            
            if (hfErrors.value == null || hfErrors.value == undefined || hfErrors.value == "")
            {
                return null;
            }
        
            return hfErrors.value;
        }
        
        fileUploadsListManager.getUploadedFileIdents = function()
        {
            var hfUploadedFilesIdents = document.getElementById("<%= hfUploadedFilesIdents.ClientID %>");
            
            var identsRawString = hfUploadedFilesIdents.value;
            
            return identsRawString;
        }
        
        fileUploadsListManager.setFileDeletionDate = function(fileDeletionDate)
        {
            var hfFilesDeletionDate = document.getElementById("<%= hfFilesDeletionDate.ClientID %>");
            
            hfFilesDeletionDate.value = fileDeletionDate;
        }
        
        parent.window.FileUploadsListManager = fileUploadsListManager;
        
        SetVisibleFileControls();
    
    </script>
</body>
</html>
